
var g_current_menu = false;
var g_admin_url = "";
var g_params = "";
var g_current_color = false;

// check form
//function g_check_form(f)
//{
//	var v = new Validator(f);
//	return v.test();
//}
// display menu
function g_menu_display(id)
{
	var menu = document.getElementById("g_menu_" + id);
	if (menu != null)
	{
		if (menu != g_current_menu)
		{
			if (g_current_menu) g_current_menu.style.display = 'none';
			menu.style.display = 'inline';
			g_current_menu = menu;
		}
	}
}
// open window
function g_open(url, width, height)
{
	var top = (screen.availHeight - height) / 2 - 30;
	var left = (screen.availWidth - width) / 2;
	var features = 'status,statusbars,scrollbars,width=' + width + ',height=' + height + ',top=' + top + ',left=' + left;
	window.open(url, '', features);
}
// get url
function g_url(params)
{
	var url = g_admin_url;

	if (params.length)
	{
		url += "?";
		if (params[0]) url += "g_job=" + params[0];
		if (params[1]) url += "&g_subjob=" + params[1];
		if (g_params != '') url += "&g_params=" + escape(g_params);

		var idx = 1;
		for (var i=2; i<params.length; i++)
		{
			url += "&id" + idx + "=" + escape(params[i]);
			idx++;
		}
	}
	return url;
}
// get art url
function g_arg_url()
{
	return g_url(arguments);
}
// goto
function g_goto()
{
	document.location.href = g_url(arguments);
}
// goto receiver
function g_goto_receiver()
{
	form_receiver.location.href = g_url(arguments);
}
// goto delete
function g_goto_delete()
{
	if (window.confirm('해당자료를 삭제처리합니다. 복구불가!!'))
	{
		form_receiver.location.href = g_url(arguments);
	}
}
// goto flag delete
function g_goto_flag_delete()
{
	if (window.confirm('해당자료를 삭제처리합니다.'))
	{
		form_receiver.location.href = g_url(arguments);
	}
}
// goto recovery
function g_goto_recovery()
{
	if (window.confirm('해당자료를 복구처리합니다.'))
	{
		form_receiver.location.href = g_url(arguments);
	}
}
// image tool tip
function g_image_tip(o, width)
{
	var tag = '';
	if (o.value != '')
	{
		var tag = "<img src='" + o.value + "'";
		if (width != null) tag += " width='" + width + "'";
		tag += ">";
	}
	o.tip = tag;
}
// file browser
function g_file_browser(callback, path, mode)
{
	var url = "/ezadm/util/file_browser/tree.htm?callback=" + callback;
	if (path) url += "&path=" + path;
	if (mode) url += "&mode=" + mode;
	window.open(url, '', 'width=570,height=500,scrollbars=no');
}
// list mouse event
function g_mouse_over(o)
{
	g_current_color = o.style.backgroundColor;
	o.style.backgroundColor = "#E7DEFA";
}
function g_mouse_out(o)
{
	o.style.backgroundColor = g_current_color;
}
// goto excel download
function g_goto_excel(url)
{
	var o = document.forms['g_excel_form'].elements['g_is_all'];
	url += "&g_frame=excel";
	if (o[0].checked) url += "&g_is_all=" + o[0].value;
	else url += "&g_is_all=" + o[1].value;
	document.form_receiver.location.href = url;
}
/*
 * 서브밋으로 넘기기
 */
function g_move_submit(){

	g_move_arg(arguments)
}

/*
 * 넘기는 처리
 */
function g_move_arg(arguments){

	var v_delimeter = ":";
	if(arguments.length>0){
		var frm = arguments[0];
		frm.target ="_self";
		var idx = 0;
		try{
			for(var i=1; i<arguments.length; i++){
				param = arguments[i];
				if(param.indexOf(v_delimeter)>0){
					var pa = param.split(v_delimeter);
					var obj_name = pa[0];
					var obj_value = pa[1];
					obj = document.getElementsByName(obj_name);
					obj[0].value = obj_value;

				}else{
					idx++;
					var newObj = document.createElement("input");
					newObj.type="hidden";
					newObj.name="id"+idx;
					newObj.id="id"+idx;
					newObj.value = param;

					frm.insertBefore(newObj, frm.firstChild);

				}
			}
			frm.submit();
		}catch (e){
			alert(e);
		}

	}
}

// goto delete
function g_delete_submit()
{
	if (window.confirm('해당자료를 삭제처리합니다. 복구불가!!'))
	{
		g_move_arg(arguments);
	}
}


// goto image view
function goto_image_view(url, w, h)
{
	window.open(url, '', "width=" + w + ",height=" + h + ",top=0,left=0");
}


function on_bigo()
{
	var url = g_arg_url('contract_bigo', 'list');
	g_open(url, 770, 750);
}